package com.thecafetechno.main;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.thecafetechno.university.Student;
import com.thecafetechno.util.HibernateUtil;

public class DataSelectionHQLExampleWithRestrictionAndOrdering {
	public static void main(String[] ar) {
		DataPopulator.populateData();
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		Transaction transaction = session.beginTransaction();
		List<Student> studentList = session
				.createQuery(
						"from Student student where student.marks>=75 order by student.name asc, student.marks desc")
				.list();
		transaction.commit();
		for (Student student : studentList) {
			System.out.println(student);
			System.out.println(student.getMarks());
		}
	}
}
